package com.maimao.model.order.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

/**
 * @author MaoLin Wang
 * @date 2021/1/18 5:26 下午
 */
@Getter
public enum OrderStatus {
    //(1-已提交-待付款，2-已付款-待发货， 5 -交易成功，6-交易取消 )
    /**
     * 待付款
     */
    NOT_PAY(1, "待付款"),
    /**
     * 已支付
     */
    PAID(2, "已支付"),

    /**
     * 交易成功
     */
    SUCCESS(5, "交易成功"),

    /**
     * 订单取消
     */
    CANCEL(6, "交易取消");

    private Integer status;
    private String msg;

    OrderStatus(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    OrderStatus(Integer status) {
        this.status = status;
    }

    public static Integer getCodeByMsg(String msg) {
        if (StrUtil.isEmpty(msg)) {
            return null;
        }
         OrderStatus.valueOf(msg);

        return null;
    }

    public static void main(String[] args) {
        Integer 交易取消 = OrderStatus.valueOf("交易取消").getStatus();
        System.out.println(交易取消);
    }

    public static String getMsgByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (OrderStatus orderStatus : values()) {
            if (orderStatus.getStatus().equals(code)) {
                return orderStatus.getMsg();
            }
        }
        return null;
    }
}
